/**
 * jims
 */
package com.jims.master.modules.blood.service;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.common.utils.ChineseCharToEnUtils;
import com.jims.master.modules.blood.dao.BloodComponentDao;
import com.jims.master.modules.blood.entity.BloodComponent;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 血液成分字典Service
 * @author fengyg
 * @version 2017-04-06
 */
@Service
@Transactional(readOnly = true)
public class BloodComponentService extends CrudService<BloodComponentDao, BloodComponent> {

	public BloodComponent get(String id) {
		return super.get(id);
	}
	/**
	 * 根据参数查询自动补全数据
	 * @param q
	 * @param limit
	 * @return
	 * @author CTQ
	 */
	public List<BloodComponent> findListByParam(String q,String limit) {
		return dao.findListByParam(q,limit);
	}
	
	public Page<BloodComponent> findPage(Page<BloodComponent> page, BloodComponent bloodComponent) {
		return super.findPage(page, bloodComponent);
	}
	
	@Transactional(readOnly = false)
	public int save(BloodComponent bloodComponent) {
        bloodComponent.setInputCode(ChineseCharToEnUtils.getAllFirstLetter(bloodComponent.getBloodName()));
		return super.save(bloodComponent);
	}
	
	@Transactional(readOnly = false)
	public int delete(BloodComponent bloodComponent) {
		return super.delete(bloodComponent);
	}

    /**
     * 血液成分自动补全
     * @param q
     * @param limit
     * @return
     * @author fengyg
     */
    public List<BloodComponent> findautoCompleteBloodComponentList(String q,String limit){
        return dao.findListByParam(q,limit);
    }
	
}